home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 July / macformat-026.iso / mac / Shareware City / Science / µSim 1.0 folder / Libs / UtilsCommon.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-09  |  7.1 KB  |  258 lines  |  [TEXT/MMCC]

  1. #ifndef __FSPCOMPAT__
  2. #include "FSpCompat.h"
  3. #endif
  4.  
  5. #if defined(FabSystem7orlater)
  6.  
  7. #define    FabStandardGetFile    StandardGetFile
  8. #define    FabStandardPutFile    StandardPutFile
  9.  
  10. #else
  11.  
  12. #include    "Utils6.h"
  13.  
  14. #endif
  15.  
  16.  
  17. //#if GENERATING68K
  18. //#pragma parameter MyNumToString(__D0,__A0)
  19. //extern pascal void MyNumToString(long theNum,Str255 theString)
  20. // TWOWORDINLINE(0x4267, 0xA9EE);
  21. //#else
  22. #define    MyNumToString    NumToString
  23. //#endif
  24.  
  25. /* WantThisHandleSafe locks high the handle and returns the previous state */
  26.  
  27. #if GENERATING68K
  28. #pragma parameter __D0 WantThisHandleSafe(__A0)
  29. extern pascal SignedByte WantThisHandleSafe(Handle myH) = {0xA069, 0x1F00, 0xA064, 0xA029, 0x101F};
  30. #else
  31. SignedByte WantThisHandleSafe(Handle myH);
  32. #endif
  33.  
  34. /* ClearHiliteMode clears the HiliteMode bit with BCLR */
  35.  
  36. /*pascal void ClearHiliteMode(void) = {0x08B8, 0x0007, 0x0938};
  37. */
  38.  
  39. #define numOfLongs(s)    (((s)>>2) - 1L)
  40.  
  41. #if GENERATING68K
  42. #pragma parameter MyZeroBuffer(__A0,__D1)
  43. extern pascal void MyZeroBuffer(long *p, long s) = {0x7000, 0x20C0, 0x51C9, 0xFFFC };
  44.  
  45. #pragma parameter MyFillBuffer(__A0,__D1,__D0)
  46. extern pascal void MyFillBuffer(long *p, long s, long filler) = {0x20C0, 0x51C9, 0xFFFC };
  47.  
  48. #pragma parameter __D0 mySwap(__D0)
  49. extern pascal long mySwap(long s) = {0x4840 };
  50. #else
  51. void MyZeroBuffer(long *p, long s);
  52. void MyFillBuffer(long *p, long s, long filler);
  53. long mySwap(long s);
  54. #endif
  55.  
  56.  
  57. #define toMenu(m, i)    (((long)m << 16) + i)
  58. #define    CHARFROMMESSAGE(mess)    (*(((unsigned char *)(&(mess))) + 3))
  59. #define ISAPPWINDOW(w)    (w && ((WindowPeek) w)->windowKind >= userKind)
  60. #define ISDAWINDOW(w)    (w && ((WindowPeek) w)->windowKind < 0)
  61. #define isMovableModal(w)    (GetWVariant(w) == movableDBoxProc)
  62.  
  63. #define MAX(a, b)    ((a) > (b) ? (a) : (b))
  64. #define MIN(a, b)    ((a) < (b) ? (a) : (b))
  65.  
  66. /* strings */
  67. enum simplestrings {
  68. kSTR_NOOPENORPRINT = -16397,
  69. kSTR_ApplicationName = -16396
  70. };
  71.  
  72. /* Menu list resource IDs */
  73. enum menures {
  74. kRes_Menu_Apple = 128,
  75. kRes_Menu_File,
  76. kRes_Menu_Edit
  77. };
  78.  
  79. enum edititems {
  80. kMItem_Undo = 1,
  81. kMItem_Cut = 3,
  82. kMItem_Copy,
  83. kMItem_Paste,
  84. kMItem_Clear
  85. };
  86.  
  87. enum {
  88. kUndoKey = 0x7A10,
  89. kCutKey = 0x7810,
  90. kCopyKey = 0x6310,
  91. kPasteKey = 0x7610,
  92. kHelpKey = 0x7205,
  93. kFwdDel = 0x757F,
  94. kHomeKey = 0x7301,
  95. kEndKey = 0x7704,
  96. kPgUpKey = 0x740B,
  97. kPgDnKey = 0x790C,
  98. kClearKey = 0x471B,
  99. kEscapeKey = 0x351B,
  100. kEnterKey = 0x4C03
  101. };
  102.  
  103. /* for KeyState */
  104. enum {
  105. kCommandKeyCode = 55,
  106. kShiftKeyCode,
  107. kCapsLockKeyCode,
  108. kOptionKeyCode,
  109. kControlKeyCode
  110. };
  111.  
  112. enum {
  113. kWantRestart = false,
  114. kWantShutdown = true
  115. };
  116.  
  117. enum {
  118. kCreat = 'FABR',
  119. kAEAlert = 'ALRT'
  120. };
  121.  
  122. enum {
  123. kSTR_RegDECALLOWED = 302,
  124. kSTR_EMAILADDR = 320,
  125. kSTR_WWWURL = 321,
  126. kDLOG_Register = 300,
  127. kDLOG_MovableAbout = 301,
  128. kDLOG_MovableCredits = 302,
  129. kDITLItem_AboutPICT = 3,
  130. kALRT_GENERICERROR = 130,
  131. kALRT_OLDSYSTEM = 131,
  132. kALRT_AEPROCESSERR = 134,
  133. kALRT_INITWINDSERROR = 136,
  134. kALRT_AEINSTALLEVTERR = 137,
  135. kALRT_REGCANNOTREPLACE = 201,
  136. kALRT_REGSUCCESSSAVED = 202,
  137. kALRT_REGDISKFULL = 203,
  138. kALRT_REGUNKNOWNWRITEERROR = 204,
  139. kALRT_REGCOULDNOTOPENFORWRITING = 205,
  140. kALRT_REGCOULDNOTCREATE = 206,
  141. kALRT_PLEASEDISMISSMOVABLEMODAL = 500,
  142. kALRT_DISMISSORDRAGANDDROP = 501
  143. };
  144.  
  145. enum {
  146. kItemUserName = 3,
  147. kItemCompany,
  148. kItemAddress,
  149. kItemCity,
  150. kItemState,
  151. kItemZIP,
  152. kItemCountry,
  153. kItemE_mail,
  154. kItemPhone,
  155. kItemFAX,
  156. kItemQuantity,
  157. kItemCopyFrom,
  158. kItemComments,
  159. kItemTotals = 27
  160. };
  161.  
  162. OSErr AddSTRRes2Doc(FSSpec *theDoc, OSType myFcrea, OSType myFtype, short STRid, ScriptCode lScript);
  163. OSErr AddSTRHand2Doc(FSSpec *theDoc, OSType myFcrea, OSType myFtype, StringHandle msgString, ScriptCode lScript);
  164. OSErr AddRes2Doc(FSSpec *theDoc, Handle thisHandle, ResType rType, short rID);
  165. void SendmyAE(AEEventClass, AEEventID myAEvtID, AEIdleProcPtr, AESendMode theMode);
  166. void SendmyAEPShort(AEEventClass myclass, AEEventID myAEvtID, AEIdleProcPtr IdleFunct, AESendMode theMode, short theAlert);
  167. void ZoomRectToRect(RectPtr startingRect, RectPtr endingRect, short numofDivs);
  168. void ZoomRectToRectAutoGrafPort(RectPtr startingRect, RectPtr endingRect, short numofDivs);
  169. Handle NewHandleGeneral(Size blockSize);
  170. Handle Get1ResGeneral(ResType theType, short theID);
  171. OSType FindFinderAtEaseProcess(ProcessSerialNumber *);
  172. OSType FindFinderProcess(void);
  173. OSErr SendShutdownToFinder(AEIdleProcPtr, Boolean);
  174. short StopAlert_UPP(short alertID, ModalFilterProcPtr filterProc);
  175. short StopAlert_AE(short alertID, ModalFilterProcPtr filterProc, AEIdleProcPtr IdleFunct);
  176. short CautionAlert_UPP(short alertID, ModalFilterProcPtr filterProc);
  177. short CautionAlert_AE(short alertID, ModalFilterProcPtr filterProc, AEIdleProcPtr IdleFunct);
  178. short NoteAlert_UPP(short alertID, ModalFilterProcPtr filterProc);
  179. short NoteAlert_AE(short alertID, ModalFilterProcPtr filterProc, AEIdleProcPtr IdleFunct);
  180. short Alert_UPP(short alertID, ModalFilterProcPtr filterProc);
  181. short Alert_AE(short alertID, ModalFilterProcPtr filterProc, AEIdleProcPtr IdleFunct);
  182.  
  183. typedef struct {
  184.     FSSpec    destFile;
  185.     ScriptCode    theScript;
  186.     } StdFileResult, *StdFileResultPtr;
  187.  
  188. /* dialog box manager */
  189.  
  190. struct dialogitems {
  191.     short    itemNumber;
  192.     short    group;
  193.     long    refCon;
  194.     };
  195.  
  196. typedef struct dialogitems dialogItems, *dialogItemsPtr;
  197.  
  198. void FlashButton(DialogPtr dlg, short item);
  199. void OutlineButton(DialogPtr oftheDialog, short myItem);
  200.  
  201. short HandleDialog(ModalFilterProcPtr filterProc,
  202.                     dialogItemsPtr things,
  203.                     void (*initProc)(DialogPtr),
  204.                     void (*userProc)(DialogPtr, Handle, short),
  205.                     short resId);
  206.  
  207. /* about box manager */
  208.  
  209. void myAbout(void (*theIdleProc)(void),
  210.             UserItemUPP DrawQTPict,
  211.             void (*UpdateProc)(EventRecord *),
  212.             void (*ActivateProc)(EventRecord *)
  213.             );
  214. Handle OpenSplash(DialogPtr *, UserItemUPP DrawQTPict);
  215. void DisposeSplash(Handle, DialogPtr);
  216. void myMovableModalAbout(
  217.             Point *aboutTopLeft,
  218.             Point *creditsTopLeft,
  219.             void (*AdjustMenus)(void),
  220.             void (*Handle_My_Menu)(long),
  221.             void (*DomyKeyEvent)(EventRecord *),
  222.             void (*DoUpdate)(EventRecord *),
  223.             void (*DoActivate)(EventRecord *),
  224.             void (*DoHiLevEvent)(EventRecord *),
  225.             void (*DoOSEvent)(EventRecord *),
  226.             void (*DoIdle)(void),
  227.             unsigned long minSleep
  228.             );
  229.  
  230. void CopyEMailAddrToClip(void);
  231. void CopyWWWURLToClip(void);
  232. Boolean GetFontNumber(ConstStr255Param fontName, short *fontNum);
  233. Boolean CmdPeriod(EventRecord *theEvent);
  234. Boolean CmdPeriodOrEsc(EventRecord *theEvent);
  235. Boolean CmdPeriodOrEscConfirm(EventRecord *theEvent, short alertID, ModalFilterProcPtr filterProc);
  236. void HandleRegistration(/*ModalFilterProcPtr filterProc,*/
  237.                         Point *regDTopLeft,
  238.                         long (*regCfgInfo)(Handle, long, StringPtr),
  239.                         void (*AdjustMenus)(void),
  240.                         void (*Handle_My_Menu)(long),
  241.                         void (*DomyKeyEvent)(EventRecord *),
  242.                         void (*DoUpdate)(EventRecord *),
  243.                         void (*DoActivate)(EventRecord *),
  244.                         void (*DoHiLevEvent)(EventRecord *),
  245.                         void (*DoOSEvent)(EventRecord *),
  246.                         void (*DoIdle)(void),
  247.                         unsigned long minSleep,
  248.                         short dollars);
  249. OSErr AskForDestFile(StdFileResultPtr whichFile, ConstStr255Param prompt, StringPtr docName);
  250. void BCDVersNumToString(long num, StringPtr str);
  251. void BCDLongVersNumToString(long num, StringPtr str);
  252. Boolean TrapAvailable(short theTrap);
  253. OSErr InstallRequiredAEHandlers(AEEventHandlerProcPtr myOAPP,
  254.                                 AEEventHandlerProcPtr myODOC,
  255.                                 AEEventHandlerProcPtr myPDOC,
  256.                                 AEEventHandlerProcPtr myQUIT);
  257.  
  258.